<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:p="http://primefaces.org/ui">

    <body>

        <ui:composition template="./adminTemplate.xhtml">

            <ui:define name="title">
                List Account
            </ui:define>

            <ui:define name="contain">
                <h:form>
                    <h2 class="ico_mug">List Account</h2>
                    <p:dataTable id="table-item" var="acc" value="#{accountController.listAcc}"
                                 paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"  
                                 rowsPerPageTemplate="10,15,20" paginator="true" rows="10">                               
                        <p:column style="text-align: center">  
                            <f:facet name="header">  
                                ID 
                            </f:facet>  
                            <h:outputText value="#{acc.ID}" />  
                        </p:column>                              
                        <p:column>  
                            <f:facet name="header">  
                                Email  
                            </f:facet>  
                            <h:outputText value="#{acc.email}"/>
                        </p:column>                       
                        <p:column>  
                            <f:facet name="header">  
                                Password 
                            </f:facet>  
                            <h:outputText value="#{acc.password}" />  
                        </p:column>
                        <p:column style="text-align: center">  
                            <f:facet name="header">  
                                Status  
                            </f:facet>  
                            <img src="img/#{acc.status}.png" border="0" /> 
                        </p:column>
                        <p:column style="text-align: center;width: 60px">  
                            <f:facet name="header">  
                                Action  
                            </f:facet>  
                            <p:commandLink action="#{accountController.selectedID(acc.ID)}" oncomplete="confirmation.show()">
                                <img src="img/delete.png" alt="trash"/>
                            </p:commandLink>
                        </p:column> 
                    </p:dataTable>
                    <p:confirmDialog id="confirmation" message="Are you sure to delete this Account?"  
                                     header="Delete Account" severity="alert" widgetVar="confirmation" > 
                        <p:commandButton value="Yes Sure" update=":form:table-item" oncomplete="confirmation.hide()"  
                                         actionListener="#{accountController.deleteAccount()}" />  
                        <p:commandButton value="Not Yet" onclick="confirmation.hide()" type="button" />   
                    </p:confirmDialog>
                </h:form>
            </ui:define>

        </ui:composition>

    </body>
</html>
